<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	<script>
		function resetData() {
			$(".header:eq(1), .content:eq(1)").hide();
		}
	</script>
</head>
<body>
<div id="app">
	<div class="header">
		<span>删除用户</span>
	</div>
	<div class="content">
		<table>
			<tr>
				<td class="text-right">手机号码</td><td class="content_right">
				<input id="phone" class="input inline-input" placeholder="请输入手机号码">
				<span class="btn btn-info" id="find">立即查找</span></td>
			</tr>
		</table>
	</div>


	<div class="header">
		<span>查找信息如下</span>
	</div>
	<div class="content">
		<table>
			<tr>
				<td class="text-right">昵称</td><td class="content_right"><input class="input" readonly></td>
			</tr>
			<tr>
				<td class="text-right">手机号码</td><td class="content_right"><input class="input" readonly></td>
			</tr>
			<tr>
				<td class="text-right">身份证号码</td><td class="content_right"><input class="input" readonly></td>
			</tr>
			<tr>
				<td class="text-right">密码</td><td class="content_right"><input class="input" readonly></td>
			</tr>
			<tr>
				<td></td><td class="content_right"><span class="btn btn-info" id="delete">立即删除</span> <span class="btn" onclick="resetData()">重置</span> </td>
			</tr>
		</table>
	</div>
</div>
</body>
<script src="/js/jquery2.1.4.js"></script>
<script src="/layer/layer.js"></script>
<script>
	$(".header:eq(1), .content:eq(1)").hide();
	var userId = null;
	var phone = null;
	var idCard = null;
	$(function () {
		$("#find").click(function () {
			var windowId = layer.load();
			phone = $("#phone").val();
			if (phone === "") {
				layer.close(windowId);
				layer.msg("手机号码不能为空！");
			}else {
				if (phone.match(/^1[3-9]\d{9}$/) === null) {
					layer.close(windowId);
					layer.msg("请输入正确的手机号码！");
				}else {
					$.getJSON("/user/find.do", {phone: phone}, function (data) {
						layer.close(windowId);
						layer.msg(data.content);
						if (data.status === 0) {
							$(".header:eq(1), .content:eq(1)").fadeIn(1000);
							userId = data.data.id;
							idCard = data.data.idCard;
							$(".input:eq(1)").val(data.data.nickName);
							$(".input:eq(2)").val(phone);
							$(".input:eq(3)").val(idCard);
							$(".input:eq(4)").val(data.data.password);
						}
					})
				}
			}
		});

		$("#delete").click(function () {
			layer.confirm("<span style='color: black;font-size: 18px'>你确定删除吗?</span>", {btn : ["确定", "取消"], title : ""}, function () {
				var windowId = layer.load();
				$.getJSON("/user/delete.do", {id: userId, phone: phone, idCard: idCard}, function (data) {
					layer.close(windowId);
					layer.msg(data.content);
					if (data.status === 0) {
						resetData();
					}
				})
			});
		});
	});
</script>
</html>
